package com.yc;

import java.io.*;
import java.net.*;

public class JokeClient {
    public static void main(String[] args) throws IOException {
        String serverAddress = "localhost";
        int serverPort = 10082;

        Socket socket = new Socket(serverAddress, serverPort);
        System.out.println("已连接到JOCK服务器 " + serverAddress + ":" + serverPort);

        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

        // 向服务器请求笑话
        out.println("得到笑话");

        // 接收服务器返回的笑话数据
        String joke = in.readLine();
        System.out.println("每天一笑: " + joke);

        socket.close();
    }
}
